package com.test.app.login;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.test.app.componentbase.ServiceFactory;
import com.test.app.componentbase.service.IAccountService;

@Route(path = "/account/login")
public class LoginActivity extends AppCompatActivity {

    Button btnLogin, btnShare;

    private IAccountService accountService;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login_activity_login);

        accountService = ServiceFactory.getInstance().getAccountService();

        btnLogin = findViewById(R.id.btn_login);
        btnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                accountService.login("1001");
                Toast.makeText(LoginActivity.this, "登录成功，账号是："+accountService.getAccountId(), Toast.LENGTH_SHORT).show();
            }
        });
        btnShare = findViewById(R.id.btn_share);
        btnShare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/share/share").navigation();
            }
        });
    }
}
